package com.contract.commonlib.http.intercept

import okhttp3.Interceptor
import okhttp3.Response
import java.io.IOException

/**
 *url拦截器
 *@author woochen
 *@time 2019/4/26 10:29
 */
class HttpHeadInterceptor : Interceptor {
    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        //构建新的请求
        val newRequest = request.newBuilder()
            .header("Content-Type", "application/json;charset=UTF-8")
            .addHeader("Accept-Encoding", "identity")
            .addHeader("transfer-encoding","chunked")
            .build()
        return chain.proceed(newRequest)
    }

}